package com.yonyougov.devops.cruxcisupport.menu;

import com.yonyougov.devops.cruxcisupport.menu.vo.AllMenuLinkRespVo;
import com.yonyougov.devops.cruxcisupport.menu.vo.NoLinkMenuByRoleIdVo;
import com.yonyougov.devops.cruxcisupport.menu.vo.NoLinkMenuPageByRoleIdDto;
import com.yonyougov.devops.fwc.core.dao.impl.BaseDaoImpl;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import java.math.BigInteger;
import java.util.List;

/**
 * t_menu数据层实现
 */
@Repository
public class MenuDaoImpl extends BaseDaoImpl<MenuEntity, BigInteger> implements MenuDao {


    //<!--用户自定义代码开始-->
    private final SqlSessionTemplate sqlSessionTemplate;

    public MenuDaoImpl(SqlSessionTemplate sqlSessionTemplate) {
        this.sqlSessionTemplate = sqlSessionTemplate;
    }

    @Override
    public List<NoLinkMenuByRoleIdVo> findNoLinkMenuPageByRoleId(NoLinkMenuPageByRoleIdDto noLinkMenuPageByRoleIdDto) {
        String statement = MenuEntity.class.getName() + "Mapper.findAllMenuNoLinkByRoleId";
        return sqlSessionTemplate.selectList(statement, noLinkMenuPageByRoleIdDto);
    }

    @Override
    public List<AllMenuLinkRespVo> findAllMenuLinkByUserId(BigInteger userId) {
        String statement = MenuEntity.class.getName() + "Mapper.findAllMenuLinkByUserId";
        return sqlSessionTemplate.selectList(statement, userId);
    }

    @Override
    public int countNoLinkMenuByRoleId(NoLinkMenuPageByRoleIdDto noLinkMenuPageByRoleIdDto) {
        String statement = MenuEntity.class.getName() + "Mapper.countByAllMenuNoLinkByRoleId";
        return sqlSessionTemplate.selectOne(statement, noLinkMenuPageByRoleIdDto);
    }
    //<!--用户自定义代码结束-->
}
